﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using PMSA.Framework.Database;

/// <summary>
/// Summary description for ProductFacade
/// </summary>
public class CProductFacade
{
    private ProductDAL db = new ProductDAL();
    private CBrandFacade brandfacade = new CBrandFacade();
    public IList<Product> List(int pageIndex, int pageMax, int groupProductId, int brandId)
    {
        IList<Product> list = null;
        DataSet ds = new DataSet();
        ds = db.List(pageIndex, pageMax, groupProductId, brandId);
        if (ds != null && ds.Tables.Count > 0)
        {
            list = CDb.MapList<Product>(ds.Tables[0]);
        }

        return list;
    }
    public Product Detail(int productId)
    {
        DataSet ds = new DataSet();
        ds = db.Detail(productId);
        Product obj = CDb.Map<Product>(ds.Tables[0]);
        return obj;
    }
    public Product UpdateStatusActive(int productId, int isActive)
    {
        DataSet ds = new DataSet();
        ds = db.UpdateStatusActive(productId, isActive);
        Product obj = CDb.Map<Product>(ds.Tables[0]);
        return obj;
    }
    public Product Insert(string name, string unit, int price, string description, int isActive,
        int groupProductId, int brandId, string img1, string img2, string img3, string img4, string img5)
    {
        DataSet ds = new DataSet();
        ds = db.Insert(name, unit, price, description, isActive, groupProductId, brandId, img1, img2, img3, img4, img5);
        Product obj = CDb.Map<Product>(ds.Tables[0]);
        return obj;
    }
    public Product Update(int productid, string name, string unit, int price, string description, int isActive,
        int groupProductId, int brandId, string img1, string img2, string img3, string img4, string img5)
    {
        DataSet ds = new DataSet();
        ds = db.Update(productid, name, unit, price, description, isActive, groupProductId, brandId, img1, img2, img3, img4, img5);
        Product obj = CDb.Map<Product>(ds.Tables[0]);
        return obj;
    }
}